<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/3/16
  Time: 16:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>我的丢失物品的发布</title>
    <script src="/layui/jquery-3.6.0.min.js"></script>
</head>
<style>
    body{background: #f2f2f2;}
</style>

<body class="layui-layout-body">

<div class="layui-layout layui-layout-admin">
    <div class="layui-header">

        <!-- 头部区域（可配合layui已有的水平导航） -->
        <%@include file="head.jsp"%>
    </div>

    <%@include file="list.jsp"%>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 300px;">
            <br>
            <br>
            <table class="layui-hide" id="test" lay-filter="test"></table>

        </div>
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        我爱学习
    </div>
</div>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
</script>
<script>
    layui.use('table', function(){
        var table = layui.table;

        //温馨提示：默认由前端自动合计当前行数据。从 layui 2.5.6 开始： 若接口直接返回了合计行数据，则优先读取接口合计行数据。
        //详见：https://www.layui.com/doc/modules/table.html#totalRow
        table.render({
            elem: '#test'
            ,url:'/gooduser.do'
            ,high:1000
            ,width:900
            ,title: '用户数据表'
            ,cols: [[
                {field:'goodId', title:'物品ID', width:120,sort: true,align: 'center'}
                ,{field:'goodName', title:'物品名称', width:120,sort: true,align: 'center'}
                ,{field:'goodExplain', title:'描述', width:300,align: 'center'}
                ,{field:'goodAddress', title:'丢失地点', width:300, sort: true,align: 'center'}
                ,{field:'status', title:'操作', width:80,toolbar:'#barDemo',align: 'center'}
            ]]
        });

        //工具栏事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
            if(obj.event === 'edit'){
                layer.confirm("确认已经归还了吗？",function (index){
                    obj.del();
                    $.ajax({url: "${pageContext.request.contextPath}/usergooddel?goodId=" + data.goodId})

                    layer.close(index);
                });
            }

        });
    });
</script>




</body>

</html>